/*
 * This program is builded for testing a 
 * interview test that"make cup load 50% stead"
 * 2008-10-21 23:31:56 
 * modify this class to a Thread class
 * It seen that a death loop can not fit the request,it can
 * make the CUP suing 50% when I test this class in company,but
 * it did't work on my machine.
 * 2008-10-22 9:25:03
 * No matter how big the <max> is , the CUP just stay in 50% when I
 * run this program in Office company CUP-Core E6300 2.33G
 * 结论：当循环次数超过一定数值，其实就相当于死循环了。在死循环的情况下，公司的电脑CUP的占用率
 * 为50%，所以当下面程序中休眠时间足够短，循环次数足够多的时候，双核CUP只会在停留在50%的占用率。
 * 但是在CUP的示意图中可以看出，其中一个CUP占有率已经接近100%。这是由于下面这个程序式单线程的。
 * 如果运行两个这样的程序，两个CUP占用率将都达到100%。
 */
package charles.testproject.MakeCUPworkON50percent;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class MakeCUPworkON50percent extends Thread {
	@Override
	public void run() {
		while(true) {
			try {
				Thread.sleep(10);
				count();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	

	private void count() {
		double i = 0;
		double max = 960000000.0 * 2;
		while(i < max) {
			i ++;
		}
	}



	public static void main(String[] args) {
		MakeCUPworkON50percent sta = new MakeCUPworkON50percent();
		sta.start();
	}
}
